package com.nf.action;

import com.nf.entity.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.interceptor.SessionAware;

import java.util.Map;

public class UserAction extends ActionSupport implements ModelDriven<User>,SessionAware{

    private Map<String,Object> session = null;
    private User user = null;

    public User getModel() {
        this.user = new User();
        return this.user;
    }

    public void setSession(Map<String, Object> map) {
        this.session = map;
    }

    public String loginView(){
        return "loginViewSuccess";
    }

    public String login(){
        if ("admin".equals(user.getUserName())&&"123456".equals(user.getUserPassword())){
            session.put("user",user);
            return this.SUCCESS;
        }else{
            return this.ERROR;
        }

    }
}
